home *** CD-ROM | disk | FTP | other *** search
- #include <ctype.h>
- #include "global.h"
- #include "mbuf.h"
- #include "iface.h"
- #include "ax25.h"
- #include "ip.h"
- #include "timer.h"
-
- #define iscallsign(c) ((isupper(c)) || (isdigit(c)) || (c =='\x20'))
- int axheard_filter_flag = AXHEARD_PASS;
-
- static struct lq *al_create __ARGS((struct iface *ifp,char *addr));
- struct lq *al_lookup __ARGS((struct iface *ifp,char *addr,int sort));
- static struct ld *ad_lookup __ARGS((struct iface *ifp,char *addr,int sort));
- static struct ld *ad_create __ARGS((struct iface *ifp,char *addr));
-
- struct ld *Ld;
- struct lq *Lq;
-
- /* Log the source address of an incoming packet */
- void
- logsrc(ifp,addr)
- struct iface *ifp;
- char *addr;
- {
- register struct lq *lp;
-
- if(addreq(addr,ifp->hwaddr))
- return; /* Don't log our own packets if we hear them */
-
- if(axheard_filter_flag & AXHEARD_NOSRC)
- return;
- {
- register unsigned char c;
- register int i = 0;
- while(i < AXALEN-1){
- c = *(addr+i);
- c >>= 1;
- if(!iscallsign(c))
- return;
- i++;
- }
- }
-
- if((lp = al_lookup(ifp,addr,1)) == NULLLQ)
- if((lp = al_create(ifp,addr)) == NULLLQ)
- return;
- lp->currxcnt++;
- lp->time = Clock;
- }
- /* Log the destination address of an incoming packet */
- void
- logdest(ifp,addr)
- struct iface *ifp;
- char *addr;
- {
- register struct ld *lp;
-
- if(axheard_filter_flag & AXHEARD_NODST)
- return;
- {
- register unsigned char c;
- register int i = 0;
- while(i < AXALEN-1){
- c = *(addr+i);
- c >>= 1;
- if(!iscallsign(c))
- return;
- i++;
- }
- }
-
- if((lp = ad_lookup(ifp,addr,1)) == NULLLD)
- if((lp = ad_create(ifp,addr)) == NULLLD)
- return;
- lp->currxcnt++;
- lp->time = Clock;
- }
-
- struct lq *al_lookup(ifp,addr,sort)
- struct iface *ifp;
- char *addr;
- int sort;
- {
- register struct lq *lp;
- struct lq *lplast = NULLLQ;
-
- for(lp = Lq;lp != NULLLQ;lplast = lp,lp = lp->next){
- if(addreq(lp->addr,addr) && lp->iface == ifp){
- if(sort && lplast != NULLLQ){
- /* Move entry to top of list */
- lplast->next = lp->next;
- lp->next = Lq;
- Lq = lp;
- }
- return lp;
- }
- }
- return NULLLQ;
- }
-
- /* Create a new entry in the AX.25 link table */
- static struct lq *al_create(ifp,addr)
- struct iface *ifp;
- char *addr;
- {
- register struct lq *lp;
-
- lp = (struct lq *)callocw(1,sizeof(struct lq));
- memcpy(lp->addr,addr,AXALEN);
- lp->next = Lq;
- Lq = lp;
- lp->iface = ifp;
-
- return lp;
- }
- /* Look up an entry in the destination database */
- static struct ld *ad_lookup(ifp,addr,sort)
- struct iface *ifp;
- char *addr;
- int sort;
- {
- register struct ld *lp;
- struct ld *lplast = NULLLD;
-
- for(lp = Ld;lp != NULLLD;lplast = lp,lp = lp->next){
- if((lp->iface == ifp) && addreq(lp->addr,addr)){
- if(sort && lplast != NULLLD){
- /* Move entry to top of list */
- lplast->next = lp->next;
- lp->next = Ld;
- Ld = lp;
- }
- return lp;
- }
- }
- return NULLLD;
- }
- /* Create a new entry in the destination database */
- static struct ld *ad_create(ifp,addr)
- struct iface *ifp;
- char *addr;
- {
- register struct ld *lp;
-
- lp = (struct ld *)callocw(1,sizeof(struct ld));
- memcpy(lp->addr,addr,AXALEN);
- lp->next = Ld;
- Ld = lp;
- lp->iface = ifp;
-
- return lp;
- }
-
-